<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增学生信息')" />
</head>
<body class="white-bg">

	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-stu-add">

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学号：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuId" id="stuId" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">姓名：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuName" id="stuName" required>
						</div>
					</div>
				</div>

			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">曾用名：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="stuPastName" name="stuPastName" >
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">性别：</label>
						<div class="col-sm-8">
							<select name="stuSex" class="form-control m-b">
								<option   th:value="男"> 男</option>
								<option   th:value="女"> 女</option>
							</select>
						</div>
					</div>
				</div>

			</div>





			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">出生日期：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="stuBirth" autocomplete="off" name="stuBirth">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">身份证：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuIdCard" id="stuIdCard"required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">籍贯：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuProvince" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">国籍：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuCountry" required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">民族：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuNation" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">婚姻：</label>
						<div class="col-sm-8">
							<select name="stuMarriage" class="form-control m-b">
							<option   th:value="未婚"> 未婚</option>
							<option   th:value="已婚"> 已婚</option>
							</select>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">家庭住址：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuAddress" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">邮政编码：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuPostalCode" required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">政治面貌：</label>
						<div class="col-sm-8">
							<select name="stuPoliticalOutlook" class="form-control m-b">
								<option   th:value="共产党员"> 共产党员</option>
								<option   th:value="预备党员"> 预备党员</option>
								<option   th:value="共青团员"> 共青团员</option>
								<option   th:value="群众"> 群众</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">二级学院：</label>
						<div class="col-sm-8">
							<select name="stuCollege" class="form-control m-b">
								<option   th:value="商学院"> 商学院</option>
								<option   th:value="现代管理学院" > 现代管理学院</option>
								<option   th:value="土木工程学院" > 土木工程学院</option>
								<option   th:value="人工智能学院" > 人工智能学院</option>
								<option   th:value="外国语与海外教育学院"> 外国语与海外教育学院</option>
								<option   th:value="设计学院" > 设计学院</option>
								<option   th:value="儿童发展教育学院"> 儿童发展教育学院</option>
								<option   th:value="现代音乐学院" > 现代音乐学院</option>
								<option   th:value="法学院"> 法学院</option>
							</select>
						</div>
					</div>
				</div>

			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">专业：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuMajor" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">年级：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuGrade" required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">班级：</label>
						<div class="col-sm-8">
							<select name="stuClass" class="form-control m-b">
								<option   th:value="1班" >1班</option>
								<option   th:value="2班" >2班</option>
								<option   th:value="3班" >3班</option>
								<option   th:value="4班" >4班</option>
								<option   th:value="5班" >5班</option>
								<option   th:value="6班" >6班</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学籍状态：</label>
						<div class="col-sm-8">
							<select name="stuStates" class="form-control m-b">
								<option   th:value="在学">在学</option>
								<option   th:value="休学">休学</option>
								<option   th:value="保留学籍">保留学籍</option>
								<option   th:value="退学">退学</option>
								<option   th:value="毕业">毕业</option>
								<option   th:value="结业">结业</option>
								<option   th:value="其他">其他</option>
							</select>
						</div>
					</div>
				</div>

			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学制：</label>
						<div class="col-sm-8">
							<select name="stuLength" class="form-control m-b">
								<option   th:value="两年制">两年制</option>
								<option   th:value="四年制">四年制</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">培养层次：</label>
						<div class="col-sm-8">
							<select name="stuLevel" class="form-control m-b">
								<option   th:value="硕士研究生" >硕士研究生</option>
								<option   th:value="本科">本科</option>
								<option   th:value="专升本">专升本</option>
								<option   th:value="自考本科">自考本科</option>
								<option   th:value="培训生">培训生</option>
							</select>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学生类别：</label>
						<div class="col-sm-8">
							<select name="stuType" class="form-control m-b">
								<option   th:value="硕士研究生">硕士研究生</option>
								<option   th:value="本科">本科</option>
								<option   th:value="专升本">专升本</option>
								<option   th:value="自考本科">自考本科</option>
								<option   th:value="培训生">培训生</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">入学时间：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" autocomplete="off" name="stuEnterTime" required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">生源地：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuSource" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">考生号：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuExamNum" required>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">辅导员：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuInstructor" required>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">上传头像：</label>
						<div class="row">
							<div class="col-sm-6 col-md-3" style="width:38%!important;">
								<div class="thumbnail" style="line-height: 118px;display: flex;flex-direction: row">
									<input id="image"  name="stuImg" class="form-control"   type="hidden"  />
									<img name="image" src="" id="product" alt="头像" style="width: 100%;height: 100%">
								</div>
							</div>
							<div>
								<a class="btn btn-info" href="javascript:avatar()">
									<i class="fa fa-upload"></i> 点击上传
								</a>
							</div>
						</div>
					</div>
				</div>

			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "common/man";

		$("#form-stu-add").validate({
			rules:{
                stuIdCard:{
                    isIdCardNo:true,
                },
                stuNation:{
                    isStuNation:true,
                },
                stuMarriage:{
                    isStuMarriage:true,
                },
                stuPoliticalOutlook:{
                    isStuPoliticalOutlook:true
                },
                stuPostalCode:{
                    isStuPostalCode:true
                }
			},
			focusCleanup: true
		});
        $(function () {
            $("#product")[0].src=ctx + 'img/pitera.png'

        })
        /*用户上传头像*/
        function avatar() {
            var url = prefix + '/avatar';
            $.modal.open("头像上传", url);
        }
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-stu-add').serialize());
	        }
	    }
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#stuEnterTime',
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {

                }
            });
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#stuBirth',
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {

                }
            });
        });
		$(function() {
			jQuery.validator.addMethod("isIdCardNo", function (value, element){
				return this.optional(element) || isIdCardNo(value);
			},"请正确输入您的身份证号码");
			jQuery.validator.addMethod("isStuNation", function (value, element){
				return this.optional(element) || minzu(value);
			},"请正确输入正确的民族");
			jQuery.validator.addMethod("isStuMarriage", function (value, element){
				return this.optional(element) || hunyin(value);
			},"请正确输入已婚或未婚");
			jQuery.validator.addMethod("isStuPoliticalOutlook", function (value, element){
				return this.optional(element) || zhengzhi(value);
			},"请正确输入正确的政治面貌");
			jQuery.validator.addMethod("isStuPostalCode", function (value, element){
				return this.optional(element) || youzheng(value);
			},"请正确输入邮政编码");
			jQuery.validator.addMethod("isStuExamNum", function (value, element){
				return this.optional(element) || kaoshenghao(value);
			},"请正确输入考生号");
			function isIdCardNo(num) {
				var factorArr = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5,8, 4, 2, 1];
				var parityBit = ["1", "0", "X", "9", "8", "7", "6", "5", "4","3", "2"];
				var varArray= [];
				var lngProduct = 0;
				var intCheckDigit;
				var intStrLen = num.length;
				var idNumber= num;
				//initialize
				if(intStrLen !== 18) {
					return false;
				}
				// check andset value
				for (i = 0;i < intStrLen; i++) {
					varArray[i] = idNumber.charAt(i);
					if ((varArray[i] < '0' || varArray[i]> '9') && (i !== 17)){
						return false;
					} else if (i < 17) {
						varArray[i] = varArray[i] * factorArr[i];
					}
				}
				if(intStrLen === 18) {
					//check date
					var date8 = idNumber.substring(6, 14);
					if (!isDate8(date8)) {
						return false;
					}
					// calculate the sum of the products
					for (i = 0; i < 17; i++) {
						lngProduct = lngProduct + varArray[i];
					}
					// calculate the check digit
					intCheckDigit = parityBit[lngProduct % 11];
					// check last digit
					if (varArray[17] != intCheckDigit) {
						return false;
					}
				}else{
					return false;
				}
				return true;
			}
			function isDate8(sDate) {
				if(!/^[0-9]{8}$/.test(sDate)) {
					return false;
				}
				var year,month, day;
				year =sDate.substring(0, 4);
				month =sDate.substring(4, 6);
				day =sDate.substring(6, 8);
				var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31];
				if (year< 1700 || year > 2500) {
					return false;
				}
				if (((year %4 == 0) && (year % 100 != 0)) ||(year % 400 == 0)) {
					iaMonthDays[1] = 29;
				}
				if (month< 1 || month > 12) {
					return false;
				}
				return !(day < 1 || day > iaMonthDays[month - 1]);
			}


			function  minzu(value) {
				var min="汉族、蒙古族、回族、藏族、维吾尔族、苗族、彝族、壮族、布依族、朝鲜族、满族、侗族、瑶族、白族、土家族、哈尼族、哈萨克族、傣族、黎族、僳僳族、佤族、畲族、高山族、拉祜族、水族、东乡族、纳西族、景颇族、柯尔克孜族、土族、达斡尔族；\n" +
						"\n" +
						"仫佬族、羌族、布朗族、撒拉族、毛南族、仡佬族、锡伯族、阿昌族、普米族、塔吉克族、怒族、乌孜别克族、俄罗斯族、鄂温克族、德昂族、保安族、裕固族、京族、塔塔尔族、独龙族、鄂伦春族、赫哲族、门巴族、珞巴族、基诺族"
				var zu=min.split("、");
				for (var i = 0; i <zu.length ; i++) {
					if(value==zu[i])
					{
						return true
					}
				}
				return false
			}
			function hunyin(value) {
				if(value=="已婚"||value=="未婚")
				{
					return true
				}
				return false
			}
			function zhengzhi(value) {
				if(value=="群众"||value=="中共党员"||value=="共青团员"||value=="预备党员")
				{
					return true
				}
				return false
			}
			function youzheng(value) {
				var re = /^[1-9][0-9]{5}$/
				if(re.test(value))
				{
					return true
				}
				return false
			}
			function kaoshenghao(value) {
				var ksh = /^[1-9][0-9]{13}$/
				if(ksh.test(value))
				{
					return true
				}
				return false
			}
		})
	</script>
</body>
</html>
